package org.jprobe.codegen;

import java.lang.reflect.Method;
/**
 * Code Generator specifications
 * @author
 * @version 2.0
 * @since 1.0
 */
public interface CodeGeneratorInterface {

	/**
	 * gets array <a href='http://docs.oracle.com/javase/6/docs/api/java/lang/ClassLoader.html#name'>binary name</a> including the package name then the class name,
	 * e.g:
	 * <pre>
	 * 		"java.lang.String[]"
	 * 		"java.util.HashMap"
	 * 		"java.lang.String"
	 * 		"javax.swing.JSpinner$DefaultEditor"
	 * 		"java.security.KeyStore$Builder$FileBuilder$1"
	 * 		"java.net.URLClassLoader$3$1"
	 * </pre>
	 * @param type the class from which the binary name is extracted
	 * @return class binary name
	 */
	String getBinaryName(Class<?> type);

	/**
	 * construct an initialized array of a given type
	 * @param array an array of given type
	 * @return array literal
	 * @throws CodeGenException if the class in not array, or is null
	 */
	String getArrayAsString(Class<?> array);

	/**
	 * gets an instance of any object after making it cooked and ready for use
	 * an example of the code generated is as follows:<pre>
	 * public final class booleanJProbe{
	 * 	public boolean $() { return true; }
	 * }

	 * public final class booleanAJProbe{
	 * 	public boolean[] $() { return new boolean[]{true}; }
	 * }
	 *
	 * public final class intAAJProbe{
	 * 	public int[][] $() { return new int[][]{{1}}; }
	 * }
	 *
	 * public final class ObjectAAAJProbe{
	 * 	public Object[][][] $(){ return new Object[][][]{{{new Object()}}}; }
	 * }
	 * </pre>
	 * @param abstrakt an abstract class to be implemented
	 * @return interface implementation
	 * @throws CodeGenException if the class is null, or will fall in an infinite loop because of recursion
	 */
	String getInstantiationCode(final Class<?> clazz);

	/**
	 * gets dummy methods implementation, can be used in abstract classes/interfaces
	 * implementation
	 * @param type an interface OR abstract class to be implemented
	 * @return methods implementation source code
	 */
	String getDummyMethodsImplementation(Class<?> initializeWhat,Class<?> initializedBy);
	//String getDummyMethodsImplementation(final Class<?> type);
	/**
	 * gets the signature of a method
	 * @param method a method in a class
	 * @return the signature of a method
	 */
	String getSignature(Method method);
	/**
	 * gets the declaration of parameters, this method can be
	 * used to make a constructor/methods parameters ready for use
	 * @param types the class types of parameters
	 * @return string representation of the parameters
	 */
	String getParametersDeclaration(Class<?>[] types);
	/**
	 * gets the implementation of a class,
	 * @param clazz the class to be implemented
	 * @return array of string with the first item is the name of the package,
	 * and the other is the code implementation
	 */
	ImplementationInterface getImplementation(Class<?> clazz);
}